package com.maotai.llzhou.timetask;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.maotai.llzhou.service.MaotaiService;
import com.maotai.llzhou.thread.MaotaiYuYueLoginThread512;

/**
 * 登录并且将商品加入到购物车
 */
public class MaotaiYuYueLoginTask512 {

	@Resource(name = "maotaiService")
	private MaotaiService maotaiService;

	public void beginTask() {
		try {
			List<Map<String, Object>> list = maotaiService
					.getZhanghaoYuYueLogin512();
			if (list != null && list.size() > 0) {
				// 获取alisession
				// 这个数量可以调节，不然浪费ip
//				JSONArray jArray = IPFactory.getIpAndPort();
				int count = list.size();
//				int countData = jArray.size();
//				if (countData < count) {
//					count = countData;
//				}
				for (int i = 0; i < count; i++) {
					Map<String, Object> zhanghao = list.get(i);
//					JSONObject jj = (JSONObject) jArray.get(i);
//					String ipAndPort = jj.getString("ip") + ":"
//							+ jj.getString("port");
					zhanghao.put("loginstatus", "1");
					maotaiService.updateZhanghaoLoginStatus(zhanghao);
					MaotaiYuYueLoginThread512 myyt = new MaotaiYuYueLoginThread512(
							maotaiService, zhanghao);
					myyt.start();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
